package com.csw.shuanfa.CodeImprove.CompleteFutureLinkedBlockingQueue.YiBu;

import java.util.concurrent.atomic.AtomicInteger;


public class ThreadJiaoTiTest {


    public static void main(String[] args) {
        Thread thread1 = new Th(0);
        Thread thread2 = new Th(1);
        thread1.start();
        thread2.start();
    }
}

class Th extends Thread {
    static AtomicInteger num = new AtomicInteger();
    int id;

    public Th(int i) {
        this.id = i;
    }

    @Override
    public void run() {
        while (num.get() < 9) {
            if (num.get() % 2 == id) {
                //Thread.currentThread().getName() + "]" + num.get());
                num.getAndIncrement();

            }
        }
    }
}
